<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>电子商务售前单</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
	<style>

	</style>
    
</head>
<body >
  <span style="color: red">建议输入快递单号和物流公司,单号和物流公司使用空格分开，多个单号使用换行区分<span style="font-size: 20px"></span>,一次查询数量控制在800以内</span>
 <fieldset id="fd1" style="border: 1px solid gray;">
        <legend><span>快递单号</span></legend>
    
      <textarea class="mini-textbox-input" autocomplete="off" placeholder="在此处输入快递单号，建议复制Excel文件 快递单号和物料公司两列粘贴到输入框,格式 快递单号[空格]快递公司  例如:
      12345 ZTO
      23456 申通
      "  id='expcodes' name="" style="height: 200px;"></textarea>
    
   
    </fieldset>
   <a class="mini-button" onclick="search()" enabled="" id='query-bt'  style="margin-top: 5px">&nbsp;&nbsp;查询&nbsp;&nbsp;</a>
 
   
    <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
    buttons="#tabsButtons"
>
    <div title="明细" >
   
   <div id="datagrid1" class="mini-datagrid" style="height:330px;width: 100%;" 
        url="/exp/queryres" idField="id" sizeList="[1000]"  showFilterRow="true"
       onvaluechanged="onFilterChanged"
    >
    
        <div property="columns">
           <div field="expNo"  headerAlign="center"  >快递单号
                <input property="editor" class="mini-textbox" style="width:100%;" />
                <input id="expNo" property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged"
                />
            </div>   
             <div field="expCom"  headerAlign="center"  >快递公司
                <input property="editor" class="mini-textbox" style="width:100%;" />
                <input id="expCom"  property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged" />
            </div>    
            
             <div field="expStatus"  headerAlign="center" width='50px' >快递状态
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>           
            
            <div field="start"  headerAlign="center"  >揽件时间
                <input property="editor" class="mini-datepicker" valueType='string' style="width:100%;" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" />
            </div> 
            
            
            <div field="startInfo"  headerAlign="center"  >揽件信息
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
              <div field="end"   headerAlign="center"  >签收时间
                <input property="editor" class="mini-datepicker" valueType='string' style="width:100%;" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" />
              
            </div>  
            
              <div field="endInfo"   headerAlign="center"  >签收信息
                <input property="editor" class="mini-datepicker"  valueType='string' style="width:100%;"  />
            </div>  
  
        </div>
    </div>
    
    </div>
    <!-- <div title="Tab2" iconCls="" >
        2
    </div> -->
</div>

  <div id='editForm1'>
    <br/>
    <a class="mini-button" onclick="exportexcel()" enabled="" id='query-bt' >&nbsp;&nbsp;导出EXCEL&nbsp;&nbsp;</a>

  </div>
</body>
<script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.setPageSize(1000);
        grid.on("drawcell", function (e) {
        var record = e.record,
        column = e.column,
        field = e.field,
        value = e.value;

            //格式化日期
            if (field == "start"||field=='end') {
                if(value==''){
               	 e.cellHtml = '';
                }else{
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
                }
            }

            if (field == "expStatus") {
           	 e.cellHtml = value==2?"已签收":(value==0?'无信息':(value==3?"异常":"未签收"));
            }

        });



        function onFilterChanged(e) {
            var expnobox = mini.get("expNo");
            var expcombox = mini.get("expCom");   
         
            var expno = expnobox.getValue().toLowerCase();
            var expcom = expcombox.getValue().toLowerCase(); 
 			
            //多条件组合过滤
            grid.filter(function (row) {

               
                var r1 = true;
                if (expnobox) {
                    r1 = String(row.expNo).toLowerCase().indexOf(expno) != -1;
                }

             
                var r2 = true;
                if (expcombox) {
                    r2 = String(row.expCom).toLowerCase().indexOf(expcom) != -1;
                }
                return r1 && r2 ;
            })

               
            }
        

        var querstatus =false;
        function search(){
        	var codes =jQuery("#expcodes").val();
        	$.ajax({
				url:'/index.php?m=&c=exp&a=doexpressquery',
				data:{codes:codes},
				success:function(data){
					if(data.code==0){
					querstatus=true;
					loading('查询中----');
					}else{
						mini.alert(data.msg);
					}
				},
				dataType:'json',
				type:'post',
				async: false,

                })
        }


        window.setInterval('checkstatus()', 3000);
        function checkstatus(){
			if(querstatus==false){
				return;
			}
            
        	$.ajax({
				url:'/exp/checkQuerystatus',
				success:function(data){
					if(data==0){
						  mini.unmask(document.body);
						  grid.load();
						  querstatus = false;
					 }else{
						 loading('剩余查询数量 ['+data+']');
						 }
					
					}

                })

            }
    

   
        function loading(msg) {
            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: msg
            });

        }

        function exportexcel(){
        	location.href='/exp/export';
         }

        
    </script>

</html>